package lhc.alg.top100;

/**
 * description: https://leetcode.cn/problems/remove-duplicates-from-sorted-array/
 *  有序 快慢指针
 * author: hongchen.liao
 * date:  2022/7/27
 */
public class _26_Delete_sort_array_repetitive_num {

    class Solution {
        public int removeDuplicates(int[] nums) {
            int n = nums.length;
            if(n == 0){
                return 0;
            }
            int fast = 1, slow = 1;
            while(fast < n){
                if(nums[fast] != nums[fast-1]){
                    nums[slow] = nums[fast];
                    ++slow;
                }
                ++fast;
            }
            return slow;
        }
    }

}
